package com.emm.yixun.openapi.hander;

import net.sf.ehcache.CacheManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emm.yixun.common.app.GetCustomerDetailReqDto;
import com.emm.yixun.common.app.GetCustomerDetailResDto;
import com.emm.yixun.common.exception.XFUNExceptionCode;
import com.emm.yixun.customer.service.app.CustomerServiceAppFacade;
import com.emm.yixun.openapi.dto.base.BaseRequestDTO;
import com.emm.yixun.openapi.dto.base.BaseResponseDTO;
import com.emm.yixun.openapi.hander.base.CommonAbstractHander;
import com.emm.yixun.openapi.vo.GetCustomerDetailReqVo;

/**
 * 查询客户详情
 * @author Administrator
 *
 */
@Service("getCustomerDetailHander")
public class GetCustomerDetailHander extends CommonAbstractHander{
	
	@Autowired
	private CustomerServiceAppFacade customerServiceAppFacade;
	@Autowired
	private CacheManager cacheManager;
	
	@SuppressWarnings("rawtypes")
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		GetCustomerDetailReqVo req = (GetCustomerDetailReqVo)reqDto;
		GetCustomerDetailReqDto reqDto1 = req.getParams();
		BaseResponseDTO<GetCustomerDetailResDto> res = new BaseResponseDTO<GetCustomerDetailResDto>();
		GetCustomerDetailResDto resDto = new GetCustomerDetailResDto();
		try{
			/*
			Cache  cache = cacheManager.getCache("activeSessionsCache");
			//获取userCode缓存对应value值
			String u_userCode = reqDto1.getMerchantId() + reqDto1.getUserId() + "userCode";//获取userCode缓存key
			Element element_userCode = cache.get(u_userCode );
			String ele_userCode = (String) element_userCode .getValue();
			//获取userCode缓存key
			String u_projectId = reqDto1.getMerchantId() + reqDto1.getUserId() + "projectId";
			Element element_projectId = cache.get(u_projectId );
			String ele_projectId= (String) element_projectId .getValue();//获取userCode缓存对应value值
			
			reqDto1.setUserCode(ele_userCode);
			reqDto1.setProjectId(Long.parseLong(ele_projectId));
			*/
			resDto = customerServiceAppFacade.getCustomerDetail(reqDto1);
		} catch (Exception e) {
			e.printStackTrace();
			resDto.setErrorCode(XFUNExceptionCode.UNKNOW_EXCEPTON.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.UNKNOW_EXCEPTON.getDesout());
			resDto.setResult("0");
		}
		res.setResData(resDto);
		return res;
	}
	
}
